//
//  HLivegoldView.m
//  linktuIOS
//
//  Created by hejunsong on 17/1/13.
//  Copyright © 2017年 tianxie. All rights reserved.
//

#import "HLivegoldView.h"
#import "Masonry.h"
@interface HLivegoldView()
@property(nonatomic,strong) UILabel *titleLable;
@property(nonatomic,strong) UILabel *numberLable;

@property(nonatomic,strong) UIImageView *iconImageView;




@end

@implementation HLivegoldView

-(instancetype)init
{
    if(self = [super init])
    {
        [self makeUI];
        [self makeMasonry];
    }
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self makeUI];
        [self makeMasonry];
        UITapGestureRecognizer *gisture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Tapclick:)];
        [self addGestureRecognizer:gisture];
        
    }
    return self;
}
-(void)makeUI
{
    _titleLable     = [UILabel new];
    _numberLable    = [UILabel new];
    _iconImageView  = [UIImageView new];
    
    _numberLable.textColor = [UIColor whiteColor];
    _titleLable .textColor = [UIColor whiteColor];
    
    _titleLable.font = [UIFont systemFontOfSize:12];
    _numberLable.font = [UIFont systemFontOfSize:12];
    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius  = 10;
    
    _titleLable.text = [NSString stringWithFormat:@"%@:",NSLTLocalizedString(@"金币", nil)];
    _numberLable.text = @"  ";
//    _iconImageView.backgroundColor = [UIColor redColor];
    
    _iconImageView.image = [UIImage imageNamed:@"right_arrow_live"];
    
    [self addSubview:_titleLable];
    [self addSubview:_numberLable];
    [self addSubview:_iconImageView];
    
}
-(void)makeMasonry
{
    [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(10);
        make.centerY.mas_equalTo(self.centerY).offset(0);
    }];
    
    [_numberLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_titleLable.mas_right).offset(0);
        make.centerY.mas_equalTo(self.centerY).offset(0);
    }];
    
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_numberLable.mas_right).offset(5);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.centerY.mas_equalTo(self.centerY).offset(0);
        make.width.mas_equalTo(@5);
        make.height.mas_equalTo(@10);
    }];

}
-(void)setGoldNumber:(NSString *)goldNumber
{
    _goldNumber = goldNumber;
    self.numberLable.text = goldNumber;
}
-(void)dealloc
{
    NSLog(@"dealloc --HLivegoldView.h");

}

-(void)Tapclick:(UITapGestureRecognizer *)gesture
{
    if(self.delegate && [self.delegate respondsToSelector:@selector(livegoldClickView:)])
    {
        [self.delegate livegoldClickView:self];
    
    }


}
@end
